package vn.edu.vttu.behoccuuchuong;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity{
	
	//Bien toan cuc
	private EditText edtNhap;
	private Button btnThucHien;
	private TextView tvwKQ, tvwKQ1,tvwKQ2,tvwKQ3,tvwKQ4,tvwKQ5,tvwKQ6,tvwKQ7,tvwKQ8;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Thamchieu();
		
	}
	private void Thamchieu()
	{
		edtNhap = (EditText)findViewById(R.id.edtNhap);
		tvwKQ = (TextView)findViewById(R.id.tvwKQ);
		tvwKQ1 = (TextView)findViewById(R.id.tvwKQ1);
		tvwKQ2 = (TextView)findViewById(R.id.tvwKQ2);
		tvwKQ3 = (TextView)findViewById(R.id.tvwKQ3);
		tvwKQ4 = (TextView)findViewById(R.id.tvwKQ4);
		tvwKQ5 = (TextView)findViewById(R.id.tvwKQ5);
		tvwKQ6 = (TextView)findViewById(R.id.tvwKQ6);
		tvwKQ7 = (TextView)findViewById(R.id.tvwKQ7);
		tvwKQ8 = (TextView)findViewById(R.id.tvwKQ8); 
	}


	public void ThucHien(View view ) {
		// TODO Auto-generated method stub
		
		//Kiem tra, neu chua nhap -> bao loi
		String Nhap = edtNhap.getText().toString();
		if(Nhap.equals(""))
		{
			Toast.makeText(getApplicationContext(), "Opps, bé chưa nhập gì mà", 1000).show();
		}
		
		int n = Integer.parseInt(edtNhap.getText().toString().trim());
		if(n >0 && n <= 10)
		{
			
			tvwKQ.setText( n  +" x " + 1 + 	" = " + n*1);
			tvwKQ1.setText(n + " x "  + 2 + " = " + n*2);
			tvwKQ2.setText(n + " x "  + 3 + " = " + n*3);
			tvwKQ3.setText(n + " x "  + 4 + " = " + n*4);
			tvwKQ4.setText(n + " x "  + 5 + " = " + n*5);
			tvwKQ5.setText(n + " x "  + 6 + " = " + n*6);
			tvwKQ6.setText(n + " x "  + 7 + " = " + n*7);
			tvwKQ7.setText(n + " x "  + 8 + " = " + n*8);
			tvwKQ8.setText(n + " x "  + 9 + " = " + n*9);
		}
		else {
			Toast.makeText(getApplicationContext(), "Bé ơi ! phải nhập số từ 1 đến 10 nhé.", 2000).show();
		}
	}
	}

